1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module sourceview.View; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.AccessibleIF; 32 private import gtk.AccessibleT; 33 private import gtk.BuildableIF; 34 private import gtk.BuildableT; 35 private import gtk.ConstraintTargetIF; 36 private import gtk.ConstraintTargetT; 37 private import gtk.ScrollableIF; 38 private import gtk.ScrollableT; 39 private import gtk.TextIter; 40 private import gtk.TextView; 41 private import gtk.Widget; 42 private import sourceview.Buffer; 43 private import sourceview.Completion; 44 private import sourceview.Gutter; 45 private import sourceview.Hover; 46 private import sourceview.IndenterIF; 47 private import sourceview.MarkAttributes; 48 private import sourceview.Snippet; 49 private import sourceview.SpaceDrawer; 50 private import sourceview.c.functions; 51 public import sourceview.c.types; 52 private import std.algorithm; 53 54 55 /** 56 * Subclass of [class@Gtk.TextView]. 57 * 58 * `GtkSourceView` is the main class of the GtkSourceView library. 59 * Use a [class@Buffer] to display text with a `GtkSourceView`. 60 * 61 * This class provides: 62 * 63 * - Show the line numbers; 64 * - Show a right margin; 65 * - Highlight the current line; 66 * - Indentation settings; 67 * - Configuration for the Home and End keyboard keys; 68 * - Configure and show line marks; 69 * - And a few other things. 70 * 71 * An easy way to test all these features is to use the test-widget mini-program 72 * provided in the GtkSourceView repository, in the tests/ directory. 73 * 74 * # GtkSourceView as GtkBuildable 75 * 76 * The GtkSourceView implementation of the [iface@Gtk.Buildable] interface exposes the 77 * [property@View:completion] object with the internal-child "completion". 78 * 79 * An example of a UI definition fragment with GtkSourceView: 80 * ```xml 81 * <object class="GtkSourceView" id="source_view"> 82 * <property name="tab-width">4</property> 83 * <property name="auto-indent">True</property> 84 * <child internal-child="completion"> 85 * <object class="GtkSourceCompletion"> 86 * <property name="select-on-show">False</property> 87 * </object> 88 * </child> 89 * </object> 90 * ``` 91 * 92 * # Changing the Font 93 * 94 * Gtk CSS provides the best way to change the font for a `GtkSourceView` in a 95 * manner that allows for components like [class@Map] to scale the desired 96 * font. 97 * 98 * ```c 99 * GtkCssProvider *provider = gtk_css_provider_new (); 100 * gtk_css_provider_load_from_data (provider, 101 * "textview { font-family: Monospace; font-size: 8pt; }", 102 * -1, 103 * NULL); 104 * gtk_style_context_add_provider (gtk_widget_get_style_context (view), 105 * GTK_STYLE_PROVIDER (provider), 106 * GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); 107 * g_object_unref (provider); 108 * ``` 109 * 110 * If you need to adjust the font or size of font within a portion of the 111 * document only, you should use a [class@Gtk.TextTag] with the [property@Gtk.TextTag:family] or 112 * [property@Gtk.TextTag:scale] set so that the font size may be scaled relative to 113 * the default font set in CSS. 114 */ 115 public class View : TextView 116 { 117 /** the main Gtk struct */ 118 protected GtkSourceView* gtkSourceView; 119 120 /** Get the main Gtk struct */ 121 public GtkSourceView* getViewStruct(bool transferOwnership = false) 122 { 123 if (transferOwnership) 124 ownedRef = false; 125 return gtkSourceView; 126 } 127 128 /** the main Gtk struct as a void* */ 129 protected override void* getStruct() 130 { 131 return cast(void*)gtkSourceView; 132 } 133 134 /** 135 * Sets our main struct and passes it to the parent class. 136 */ 137 public this (GtkSourceView* gtkSourceView, bool ownedRef = false) 138 { 139 this.gtkSourceView = gtkSourceView; 140 super(cast(GtkTextView*)gtkSourceView, ownedRef); 141 } 142 143 144 /** */ 145 public static GType getType() 146 { 147 return gtk_source_view_get_type(); 148 } 149 150 /** 151 * Creates a new `GtkSourceView`. 152 * 153 * By default, an empty [class@Buffer] will be lazily created and can be 154 * retrieved with [method@Gtk.TextView.get_buffer]. 155 * 156 * If you want to specify your own buffer, either override the 157 * [vfunc@Gtk.TextView.create_buffer] factory method, or use 158 * [ctor@View.new_with_buffer]. 159 * 160 * Returns: a new #GtkSourceView. 161 * 162 * Throws: ConstructionException GTK+ fails to create the object. 163 */ 164 public this() 165 { 166 auto __p = gtk_source_view_new(); 167 168 if(__p is null) 169 { 170 throw new ConstructionException("null returned by new"); 171 } 172 173 this(cast(GtkSourceView*) __p); 174 } 175 176 /** 177 * Creates a new #GtkSourceView widget displaying the buffer @buffer. 178 * 179 * One buffer can be shared among many widgets. 180 * 181 * Params: 182 * buffer = a #GtkSourceBuffer. 183 * 184 * Returns: a new #GtkSourceView. 185 * 186 * Throws: ConstructionException GTK+ fails to create the object. 187 */ 188 public this(Buffer buffer) 189 { 190 auto __p = gtk_source_view_new_with_buffer((buffer is null) ? null : buffer.getBufferStruct()); 191 192 if(__p is null) 193 { 194 throw new ConstructionException("null returned by new_with_buffer"); 195 } 196 197 this(cast(GtkSourceView*) __p); 198 } 199 200 /** 201 * Returns whether auto-indentation of text is enabled. 202 * 203 * Returns: %TRUE if auto indentation is enabled. 204 */ 205 public bool getAutoIndent() 206 { 207 return gtk_source_view_get_auto_indent(gtkSourceView) != 0; 208 } 209 210 /** 211 * Returns the #GtkSourceBackgroundPatternType specifying if and how 212 * the background pattern should be displayed for this @view. 213 * 214 * Returns: the #GtkSourceBackgroundPatternType. 215 */ 216 public GtkSourceBackgroundPatternType getBackgroundPattern() 217 { 218 return gtk_source_view_get_background_pattern(gtkSourceView); 219 } 220 221 /** 222 * Gets the [class@Completion] associated with @view. 223 * 224 * The returned object is guaranteed to be the same for the lifetime of @view. 225 * Each `GtkSourceView` object has a different [class@Completion]. 226 * 227 * Returns: the #GtkSourceCompletion associated with @view. 228 */ 229 public Completion getCompletion() 230 { 231 auto __p = gtk_source_view_get_completion(gtkSourceView); 232 233 if(__p is null) 234 { 235 return null; 236 } 237 238 return ObjectG.getDObject!(Completion)(cast(GtkSourceCompletion*) __p); 239 } 240 241 /** 242 * Gets the [property@View:enable-snippets] property. 243 * 244 * If %TRUE, matching snippets found in the [class@SnippetManager] 245 * may be expanded when the user presses Tab after a word in the [class@View]. 246 * 247 * Returns: %TRUE if enabled 248 */ 249 public bool getEnableSnippets() 250 { 251 return gtk_source_view_get_enable_snippets(gtkSourceView) != 0; 252 } 253 254 /** 255 * Returns the [class@Gutter] object associated with @window_type for @view. 256 * 257 * Only %GTK_TEXT_WINDOW_LEFT and %GTK_TEXT_WINDOW_RIGHT are supported, 258 * respectively corresponding to the left and right gutter. The line numbers 259 * and mark category icons are rendered in the left gutter. 260 * 261 * Params: 262 * windowType = the gutter window type. 263 * 264 * Returns: the #GtkSourceGutter. 265 */ 266 public override Gutter getGutter(GtkTextWindowType windowType) 267 { 268 auto __p = gtk_source_view_get_gutter(gtkSourceView, windowType); 269 270 if(__p is null) 271 { 272 return null; 273 } 274 275 return ObjectG.getDObject!(Gutter)(cast(GtkSourceGutter*) __p); 276 } 277 278 /** 279 * Returns whether the current line is highlighted. 280 * 281 * Returns: %TRUE if the current line is highlighted. 282 */ 283 public bool getHighlightCurrentLine() 284 { 285 return gtk_source_view_get_highlight_current_line(gtkSourceView) != 0; 286 } 287 288 /** 289 * Gets the [class@Hover] associated with @view. 290 * 291 * The returned object is guaranteed to be the same for the lifetime of @view. 292 * Each [class@View] object has a different [class@Hover]. 293 * 294 * Returns: a #GtkSourceHover associated with @view. 295 */ 296 public Hover getHover() 297 { 298 auto __p = gtk_source_view_get_hover(gtkSourceView); 299 300 if(__p is null) 301 { 302 return null; 303 } 304 305 return ObjectG.getDObject!(Hover)(cast(GtkSourceHover*) __p); 306 } 307 308 /** 309 * Returns whether when the tab key is pressed the current selection 310 * should get indented instead of replaced with the `\t` character. 311 * 312 * Returns: %TRUE if the selection is indented when tab is pressed. 313 */ 314 public bool getIndentOnTab() 315 { 316 return gtk_source_view_get_indent_on_tab(gtkSourceView) != 0; 317 } 318 319 /** 320 * Returns the number of spaces to use for each step of indent. 321 * 322 * See [method@View.set_indent_width] for details. 323 * 324 * Returns: indent width. 325 */ 326 public int getIndentWidth() 327 { 328 return gtk_source_view_get_indent_width(gtkSourceView); 329 } 330 331 /** 332 * Gets the [property@View:indenter] property. 333 * 334 * Returns: a #GtkSourceIndenter or %NULL 335 */ 336 public IndenterIF getIndenter() 337 { 338 auto __p = gtk_source_view_get_indenter(gtkSourceView); 339 340 if(__p is null) 341 { 342 return null; 343 } 344 345 return ObjectG.getDObject!(IndenterIF)(cast(GtkSourceIndenter*) __p); 346 } 347 348 /** 349 * Returns whether when inserting a tabulator character it should 350 * be replaced by a group of space characters. 351 * 352 * Returns: %TRUE if spaces are inserted instead of tabs. 353 */ 354 public bool getInsertSpacesInsteadOfTabs() 355 { 356 return gtk_source_view_get_insert_spaces_instead_of_tabs(gtkSourceView) != 0; 357 } 358 359 /** 360 * Gets attributes and priority for the @category. 361 * 362 * Params: 363 * category = the category. 364 * priority = place where priority of the category will be stored. 365 * 366 * Returns: #GtkSourceMarkAttributes for the @category. 367 * The object belongs to @view, so it must not be unreffed. 368 */ 369 public MarkAttributes getMarkAttributes(string category, int* priority) 370 { 371 auto __p = gtk_source_view_get_mark_attributes(gtkSourceView, Str.toStringz(category), priority); 372 373 if(__p is null) 374 { 375 return null; 376 } 377 378 return ObjectG.getDObject!(MarkAttributes)(cast(GtkSourceMarkAttributes*) __p); 379 } 380 381 /** 382 * Gets the position of the right margin in the given @view. 383 * 384 * Returns: the position of the right margin. 385 */ 386 public uint getRightMarginPosition() 387 { 388 return gtk_source_view_get_right_margin_position(gtkSourceView); 389 } 390 391 /** 392 * Returns whether line marks are displayed beside the text. 393 * 394 * Returns: %TRUE if the line marks are displayed. 395 */ 396 public bool getShowLineMarks() 397 { 398 return gtk_source_view_get_show_line_marks(gtkSourceView) != 0; 399 } 400 401 /** 402 * Returns whether line numbers are displayed beside the text. 403 * 404 * Returns: %TRUE if the line numbers are displayed. 405 */ 406 public bool getShowLineNumbers() 407 { 408 return gtk_source_view_get_show_line_numbers(gtkSourceView) != 0; 409 } 410 411 /** 412 * Returns whether a right margin is displayed. 413 * 414 * Returns: %TRUE if the right margin is shown. 415 */ 416 public bool getShowRightMargin() 417 { 418 return gtk_source_view_get_show_right_margin(gtkSourceView) != 0; 419 } 420 421 /** 422 * Returns %TRUE if pressing the Backspace key will try to delete spaces 423 * up to the previous tab stop. 424 * 425 * Returns: %TRUE if smart Backspace handling is enabled. 426 */ 427 public bool getSmartBackspace() 428 { 429 return gtk_source_view_get_smart_backspace(gtkSourceView) != 0; 430 } 431 432 /** 433 * Returns a [enum@SmartHomeEndType] end value specifying 434 * how the cursor will move when HOME and END keys are pressed. 435 * 436 * Returns: a #GtkSourceSmartHomeEndType value. 437 */ 438 public GtkSourceSmartHomeEndType getSmartHomeEnd() 439 { 440 return gtk_source_view_get_smart_home_end(gtkSourceView); 441 } 442 443 /** 444 * Gets the [class@SpaceDrawer] associated with @view. 445 * 446 * The returned object is guaranteed to be the same for the lifetime of @view. 447 * Each [class@View] object has a different [class@SpaceDrawer]. 448 * 449 * Returns: the #GtkSourceSpaceDrawer associated with @view. 450 */ 451 public SpaceDrawer getSpaceDrawer() 452 { 453 auto __p = gtk_source_view_get_space_drawer(gtkSourceView); 454 455 if(__p is null) 456 { 457 return null; 458 } 459 460 return ObjectG.getDObject!(SpaceDrawer)(cast(GtkSourceSpaceDrawer*) __p); 461 } 462 463 /** 464 * Returns the width of tabulation in characters. 465 * 466 * Returns: width of tab. 467 */ 468 public uint getTabWidth() 469 { 470 return gtk_source_view_get_tab_width(gtkSourceView); 471 } 472 473 /** 474 * Determines the visual column at @iter taking into consideration the 475 * [property@View:tab-width] of @view. 476 * 477 * Params: 478 * iter = a position in @view. 479 * 480 * Returns: the visual column at @iter. 481 */ 482 public uint getVisualColumn(TextIter iter) 483 { 484 return gtk_source_view_get_visual_column(gtkSourceView, (iter is null) ? null : iter.getTextIterStruct()); 485 } 486 487 /** 488 * Inserts one indentation level at the beginning of the specified lines. The 489 * empty lines are not indented. 490 * 491 * Params: 492 * start = #GtkTextIter of the first line to indent 493 * end = #GtkTextIter of the last line to indent 494 */ 495 public void indentLines(TextIter start, TextIter end) 496 { 497 gtk_source_view_indent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 498 } 499 500 /** 501 * Inserts a new snippet at @location 502 * 503 * If another snippet was already active, it will be paused and the new 504 * snippet will become active. Once the focus positions of @snippet have 505 * been exhausted, editing will return to the previous snippet. 506 * 507 * Params: 508 * snippet = a #GtkSourceSnippet 509 * location = a #GtkTextIter or %NULL for the cursor position 510 */ 511 public void pushSnippet(Snippet snippet, TextIter location) 512 { 513 gtk_source_view_push_snippet(gtkSourceView, (snippet is null) ? null : snippet.getSnippetStruct(), (location is null) ? null : location.getTextIterStruct()); 514 } 515 516 /** 517 * If %TRUE auto-indentation of text is enabled. 518 * 519 * When Enter is pressed to create a new line, the auto-indentation inserts the 520 * same indentation as the previous line. This is **not** a 521 * "smart indentation" where an indentation level is added or removed depending 522 * on the context. 523 * 524 * Params: 525 * enable = whether to enable auto indentation. 526 */ 527 public void setAutoIndent(bool enable) 528 { 529 gtk_source_view_set_auto_indent(gtkSourceView, enable); 530 } 531 532 /** 533 * Set if and how the background pattern should be displayed. 534 * 535 * Params: 536 * backgroundPattern = the #GtkSourceBackgroundPatternType. 537 */ 538 public void setBackgroundPattern(GtkSourceBackgroundPatternType backgroundPattern) 539 { 540 gtk_source_view_set_background_pattern(gtkSourceView, backgroundPattern); 541 } 542 543 /** 544 * Sets the [property@View:enable-snippets] property. 545 * 546 * If @enable_snippets is %TRUE, matching snippets found in the 547 * [class@SnippetManager] may be expanded when the user presses 548 * Tab after a word in the [class@View]. 549 * 550 * Params: 551 * enableSnippets = if snippets should be enabled 552 */ 553 public void setEnableSnippets(bool enableSnippets) 554 { 555 gtk_source_view_set_enable_snippets(gtkSourceView, enableSnippets); 556 } 557 558 /** 559 * If @highlight is %TRUE the current line will be highlighted. 560 * 561 * Params: 562 * highlight = whether to highlight the current line. 563 */ 564 public void setHighlightCurrentLine(bool highlight) 565 { 566 gtk_source_view_set_highlight_current_line(gtkSourceView, highlight); 567 } 568 569 /** 570 * If %TRUE, when the tab key is pressed when several lines are selected, the 571 * selected lines are indented of one level instead of being replaced with a `\t` 572 * character. Shift+Tab unindents the selection. 573 * 574 * If the first or last line is not selected completely, it is also indented or 575 * unindented. 576 * 577 * When the selection doesn't span several lines, the tab key always replaces 578 * the selection with a normal `\t` character. 579 * 580 * Params: 581 * enable = whether to indent a block when tab is pressed. 582 */ 583 public void setIndentOnTab(bool enable) 584 { 585 gtk_source_view_set_indent_on_tab(gtkSourceView, enable); 586 } 587 588 /** 589 * Sets the number of spaces to use for each step of indent when the tab key is 590 * pressed. 591 * 592 * If @width is -1, the value of the [property@View:tab-width] property 593 * will be used. 594 * 595 * The [property@View:indent-width] interacts with the 596 * [property@View:insert-spaces-instead-of-tabs] property and 597 * [property@View:tab-width]. An example will be clearer: 598 * 599 * If the [property@View:indent-width] is 4 and [property@View:tab-width] is 8 and 600 * [property@View:insert-spaces-instead-of-tabs] is %FALSE, then pressing the tab 601 * key at the beginning of a line will insert 4 spaces. So far so good. Pressing 602 * the tab key a second time will remove the 4 spaces and insert a `\t` character 603 * instead (since [property@View:tab-width] is 8). On the other hand, if 604 * [property@View:insert-spaces-instead-of-tabs] is %TRUE, the second tab key 605 * pressed will insert 4 more spaces for a total of 8 spaces in the 606 * [class@Gtk.TextBuffer]. 607 * 608 * The test-widget program (available in the GtkSourceView repository) may be 609 * useful to better understand the indentation settings (enable the space 610 * drawing!). 611 * 612 * Params: 613 * width = indent width in characters. 614 */ 615 public void setIndentWidth(int width) 616 { 617 gtk_source_view_set_indent_width(gtkSourceView, width); 618 } 619 620 /** 621 * Sets the indenter for @view to @indenter. 622 * 623 * Note that the indenter will not be used unless #GtkSourceView:auto-indent 624 * has been set to %TRUE. 625 * 626 * Params: 627 * indenter = a #GtkSourceIndenter or %NULL 628 */ 629 public void setIndenter(IndenterIF indenter) 630 { 631 gtk_source_view_set_indenter(gtkSourceView, (indenter is null) ? null : indenter.getIndenterStruct()); 632 } 633 634 /** 635 * If %TRUE a tab key pressed is replaced by a group of space characters. 636 * 637 * Of course it is still possible to insert a real `\t` programmatically with the 638 * [class@Gtk.TextBuffer] API. 639 * 640 * Params: 641 * enable = whether to insert spaces instead of tabs. 642 */ 643 public void setInsertSpacesInsteadOfTabs(bool enable) 644 { 645 gtk_source_view_set_insert_spaces_instead_of_tabs(gtkSourceView, enable); 646 } 647 648 /** 649 * Sets attributes and priority for the @category. 650 * 651 * Params: 652 * category = the category. 653 * attributes = mark attributes. 654 * priority = priority of the category. 655 */ 656 public void setMarkAttributes(string category, MarkAttributes attributes, int priority) 657 { 658 gtk_source_view_set_mark_attributes(gtkSourceView, Str.toStringz(category), (attributes is null) ? null : attributes.getMarkAttributesStruct(), priority); 659 } 660 661 /** 662 * Sets the position of the right margin in the given @view. 663 * 664 * Params: 665 * pos = the width in characters where to position the right margin. 666 */ 667 public void setRightMarginPosition(uint pos) 668 { 669 gtk_source_view_set_right_margin_position(gtkSourceView, pos); 670 } 671 672 /** 673 * If %TRUE line marks will be displayed beside the text. 674 * 675 * Params: 676 * show = whether line marks should be displayed. 677 */ 678 public void setShowLineMarks(bool show) 679 { 680 gtk_source_view_set_show_line_marks(gtkSourceView, show); 681 } 682 683 /** 684 * If %TRUE line numbers will be displayed beside the text. 685 * 686 * Params: 687 * show = whether line numbers should be displayed. 688 */ 689 public void setShowLineNumbers(bool show) 690 { 691 gtk_source_view_set_show_line_numbers(gtkSourceView, show); 692 } 693 694 /** 695 * If %TRUE a right margin is displayed. 696 * 697 * Params: 698 * show = whether to show a right margin. 699 */ 700 public void setShowRightMargin(bool show) 701 { 702 gtk_source_view_set_show_right_margin(gtkSourceView, show); 703 } 704 705 /** 706 * When set to %TRUE, pressing the Backspace key will try to delete spaces 707 * up to the previous tab stop. 708 * 709 * Params: 710 * smartBackspace = whether to enable smart Backspace handling. 711 */ 712 public void setSmartBackspace(bool smartBackspace) 713 { 714 gtk_source_view_set_smart_backspace(gtkSourceView, smartBackspace); 715 } 716 717 /** 718 * Set the desired movement of the cursor when HOME and END keys 719 * are pressed. 720 * 721 * Params: 722 * smartHomeEnd = the desired behavior among #GtkSourceSmartHomeEndType. 723 */ 724 public void setSmartHomeEnd(GtkSourceSmartHomeEndType smartHomeEnd) 725 { 726 gtk_source_view_set_smart_home_end(gtkSourceView, smartHomeEnd); 727 } 728 729 /** 730 * Sets the width of tabulation in characters. 731 * 732 * The #GtkTextBuffer still contains `\t` characters, 733 * but they can take a different visual width in a [class@View] widget. 734 * 735 * Params: 736 * width = width of tab in characters. 737 */ 738 public void setTabWidth(uint width) 739 { 740 gtk_source_view_set_tab_width(gtkSourceView, width); 741 } 742 743 /** 744 * Removes one indentation level at the beginning of the 745 * specified lines. 746 * 747 * Params: 748 * start = #GtkTextIter of the first line to indent 749 * end = #GtkTextIter of the last line to indent 750 */ 751 public void unindentLines(TextIter start, TextIter end) 752 { 753 gtk_source_view_unindent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 754 } 755 756 /** 757 * Keybinding signal to change case of the text at the current cursor position. 758 * 759 * Params: 760 * caseType = the case to use 761 */ 762 gulong addOnChangeCase(void delegate(GtkSourceChangeCaseType, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 763 { 764 return Signals.connect(this, "change-case", dlg, connectFlags ^ ConnectFlags.SWAPPED); 765 } 766 767 /** 768 * Keybinding signal to edit a number at the current cursor position. 769 * 770 * Params: 771 * count = the number to add to the number at the current position 772 */ 773 gulong addOnChangeNumber(void delegate(int, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 774 { 775 return Signals.connect(this, "change-number", dlg, connectFlags ^ ConnectFlags.SWAPPED); 776 } 777 778 /** 779 * Keybinding signal to join the lines currently selected. 780 */ 781 gulong addOnJoinLines(void delegate(View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 782 { 783 return Signals.connect(this, "join-lines", dlg, connectFlags ^ ConnectFlags.SWAPPED); 784 } 785 786 /** 787 * Emitted when a line mark has been activated (for instance when there 788 * was a button press in the line marks gutter). 789 * 790 * You can use @iter to determine on which line the activation took place. 791 * 792 * Params: 793 * iter = a #GtkTextIter 794 * button = the button that was pressed 795 * state = the modifier state, if any 796 * nPresses = the number of presses 797 */ 798 gulong addOnLineMarkActivated(void delegate(TextIter, uint, GdkModifierType, int, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 799 { 800 return Signals.connect(this, "line-mark-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED); 801 } 802 803 /** 804 * The signal is a keybinding which gets emitted when the user initiates moving a line. 805 * 806 * The default binding key is Alt+Up/Down arrow. And moves the currently selected lines, 807 * or the current line up or down by one line. 808 * 809 * Params: 810 * down = %TRUE to move down, %FALSE to move up. 811 */ 812 gulong addOnMoveLines(void delegate(bool, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 813 { 814 return Signals.connect(this, "move-lines", dlg, connectFlags ^ ConnectFlags.SWAPPED); 815 } 816 817 /** 818 * Keybinding signal to move the cursor to the matching bracket. 819 * 820 * Params: 821 * extendSelection = %TRUE if the move should extend the selection 822 */ 823 gulong addOnMoveToMatchingBracket(void delegate(bool, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 824 { 825 return Signals.connect(this, "move-to-matching-bracket", dlg, connectFlags ^ ConnectFlags.SWAPPED); 826 } 827 828 /** 829 * The signal is a keybinding which gets emitted when the user initiates moving a word. 830 * 831 * The default binding key is Alt+Left/Right Arrow and moves the current selection, or the current 832 * word by one word. 833 * 834 * Params: 835 * count = the number of words to move over 836 */ 837 gulong addOnMoveWords(void delegate(int, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 838 { 839 return Signals.connect(this, "move-words", dlg, connectFlags ^ ConnectFlags.SWAPPED); 840 } 841 842 /** 843 * The signal is emitted to insert a new snippet into the view. 844 * 845 * If another snippet was active, it will be paused until all focus positions of @snippet have been exhausted. 846 * 847 * @location will be updated to point at the end of the snippet. 848 * 849 * Params: 850 * snippet = a #GtkSourceSnippet 851 * location = a #GtkTextIter 852 */ 853 gulong addOnPushSnippet(void delegate(Snippet, TextIter, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 854 { 855 return Signals.connect(this, "push-snippet", dlg, connectFlags ^ ConnectFlags.SWAPPED); 856 } 857 858 /** 859 * The signal is a key binding signal which gets 860 * emitted when the user requests a completion, by pressing 861 * <keycombo><keycap>Control</keycap><keycap>space</keycap></keycombo>. 862 * 863 * This will create a [class@CompletionContext] with the activation 864 * type as %GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED. 865 * 866 * Applications should not connect to it, but may emit it with 867 * [func@GObject.signal_emit_by_name] if they need to activate the completion by 868 * another means, for example with another key binding or a menu entry. 869 */ 870 gulong addOnShowCompletion(void delegate(View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 871 { 872 return Signals.connect(this, "show-completion", dlg, connectFlags ^ ConnectFlags.SWAPPED); 873 } 874 875 /** 876 * Emitted when a the cursor was moved according to the smart home end setting. 877 * 878 * The signal is emitted after the cursor is moved, but 879 * during the [signal@Gtk.TextView::move-cursor] action. This can be used to find 880 * out whether the cursor was moved by a normal home/end or by a smart 881 * home/end. 882 * 883 * Params: 884 * iter = a #GtkTextIter 885 * count = the count 886 */ 887 gulong addOnSmartHomeEnd(void delegate(TextIter, int, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 888 { 889 return Signals.connect(this, "smart-home-end", dlg, connectFlags ^ ConnectFlags.SWAPPED); 890 } 891 }